﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Frogism.Web.Views.Money {
  public partial class TransactionListControl : System.Web.Mvc.ViewUserControl<Frogism.Web.Controllers.ITransactionViewData> {
    protected override void OnLoad(EventArgs e) {
      base.OnLoad(e);
      if(!Page.IsPostBack) {
        transactionList.DataSource = ViewData.Model.TransactionItems;
        transactionList.DataBind();
        TransCount.Text = "There are " + ViewData.Model.TransactionItems.Count().ToString() + " Transactions.";
      }
     
    }
  
    
    protected string GetAccountName(int AccountId) {
        return ViewData.Model.AccountItems.First(a => a.Id == AccountId).Name;
    }
    protected string GetCategoryName(Frogism.Core.IObjectNameBase category) {
      return category == null ? "n/a" : category.Name;
    }
  }
}
